{template '_header'}
<style type="text/css">
    .table>thead>tr>td.full, .table>tbody>tr>td.full, .table>tfoot>tr>td.full{overflow: hidden;}
</style>
<div class="page-heading"> 
    <span class='pull-right'>
        {ifp 'creditshop.goods.add'}
            <a class='btn btn-primary btn-sm' href="{php echo webUrl('creditshop/goods/add')}"><i class='fa fa-plus'></i> 添加商品</a>
        {/if}
    </span>
    <h2>商品管理 <small>数量: <span class='text-danger'>{$total}</span> 条</small></h2> </div>
    <form action="./index.php" method="get" class="form-horizontal" plugins="form">
        <input type="hidden" name="c" value="site" />
        <input type="hidden" name="a" value="entry" />
        <input type="hidden" name="m" value="ewei_shopv2" />
        <input type="hidden" name="do" value="web" />
        <input type="hidden" name="r"  value="creditshop.goods" />
	<div class="page-toolbar row m-b-sm m-t-sm">
		<div class="col-sm-4">
			<div class="input-group-btn">
				<button class="btn btn-default btn-sm"  type="button" data-toggle='refresh'><i class='fa fa-refresh'></i></button>
				{ifp 'creditshop.goods.edit'}
					<button class="btn btn-default btn-sm" type="button" data-toggle='batch'  data-href="{php echo webUrl('creditshop/goods/status',array('status'=>0))}"><i class='fa fa-circle-o'></i> 下架</button>
					<button class="btn btn-default btn-sm" type="button" data-toggle='batch' data-href="{php echo webUrl('creditshop/goods/status',array('status'=>1))}"><i class='fa fa-circle'></i> 上架</button>
				{/if}
				{ifp 'creditshop.goods.delete'}	
				     <button class="btn btn-default btn-sm" type="button" data-toggle='batch-remove' data-confirm="确认要删除吗?" data-href="{php echo webUrl('creditshop/goods/delete')}"><i class='fa fa-trash'></i> 删除</button>
				{/if}
			</div> 
		</div>
		<div class="col-sm-8 pull-right">
			<select name="cate" class='form-control input-sm select-sm' style="width:120px;">
                <option value="" {if empty($_GPC['cate'])}selected{/if} >商品分类</option>
                {loop $category $cate}
                <option value='{$cate['id']}' {if $_GPC['cate']==$cate['id']}selected{/if}>{$cate['name']}</option>
                {/loop}
			</select>
            <select name='type' class='form-control input-sm' style='width:100px;'  >
                <option value='' {if $_GPC['type']==''}selected{/if}>类型</option>
                <option value='0' {if $_GPC['type']=='0'}selected{/if}>兑换</option>
                <option value='1' {if $_GPC['type']=='1'}selected{/if} >抽奖</option>
            </select>
            <select name='status' class='form-control  input-sm' style='width:100px;'  >
                <option value='' {if $_GPC['status']==''}selected{/if}>状态</option>
                <option value='0' {if $_GPC['status']=='0'}selected{/if}>暂停</option>
                <option value='1' {if $_GPC['status']=='1'}selected{/if} >开启</option>
            </select>
			<div class="input-group">				 
				<input type="text" class="input-sm form-control" name='keyword' value="{$_GPC['keyword']}" placeholder="请输入关键词"> <span class="input-group-btn">
                <button class="btn btn-sm btn-primary" type="submit"> 搜索</button> </span>
			</div>
		</div>
	</div>
</form>
    <form action="" method="post">
            <table class="table table-hover table-responsive">
                <thead>
                <tr>
                    <th style="width:25px;"><input type='checkbox' /></th>
                    <th style="width:50px;">排序</th>
                    <th style="width:60px;">商品</th>
                    <th>&nbsp;</th>
                    <th style="width:70px;">商品类型</th>
                    <th style="width:70px;">活动类型</th>
                    <th style="width:90px;">消耗</th>
                    <th style="width: 90px;">参与/浏览</th>
                    <th style="width: 100px;text-align: center;">状态</th>
                    <th style="width: 100px;text-align: center;">操作</th>
                </tr>
                </thead>
                <tbody>
                    {loop $list $row}
                       	<td>
                            <input type='checkbox'   value="{$row['id']}"/>
                        </td>
                        <td>
                           {ifp 'creditshop.adv.edit'}
                                <a href='javascript:;' data-toggle='ajaxEdit' data-href="{php echo webUrl('creditshop/goods/property',array('type'=>'displayorder','id'=>$row['id']))}" >{$row['displayorder']}</a>
                            {else}
                                {$row['displayorder']}
                            {/if}
                        </td>
                        <td>
                            <img src="{php echo tomedia($row['thumb'])}" style="width:40px;height:40px;padding:1px;border:1px solid #ccc;"  />
                        </td>
                        <td class='full'>
                          {if !empty($row['subtitle'])}<span class='label label-warning'>{$row['subtitle']}</span><br/>{/if}
                          <span class='text-danger'>[{$category[$row['cate']]['name']}]</span><br/>
                            {$row['title']}
                        </td>
                            <td style="text-align: center;">
                                {if $row['goodstype']==0}
                                <span class='label label-primary'>商品</span>
                                {elseif $row['goodstype']==1}
                                <span class='label label-success'>优惠券</span>
                                {elseif $row['goodstype']==2}
                                <span class='label label-warning'>余额</span>
                                {elseif $row['goodstype']==3}
                                <span class='label label-danger'>红包</span>
                                {/if}
                            </td>
                          <td style="text-align: center;">
							  {if $row['type']==1}
                              <span class='label label-danger'>抽奖</span>
                              {else}
                              <span class='label label-primary'>兑换</span>
                              {/if}
                               </td>
 
                         <td>{if $row['credit']>0}-{$row['credit']}积分<br/>{/if}
                              {if $row['money']>0}
                              -{$row['money']}现金
                              {/if}
                         </td>
                         <td>{$row['joins']}/{$row['views']}</td>
                        <td style="text-align: center;">
                                <span style="display: none;" class='label {if $row['istop']==1}label-success{else}label-default{/if}'
                                  {ifp 'creditshop.goods.edit'}
                                      data-toggle='ajaxSwitch'
                                      data-switch-value='{$row['istop']}'
                                      data-switch-value0='0||label label-default|{php echo webUrl('creditshop/goods/property',array('type'=>'istop', 'value'=>1,'id'=>$row['id']))}'
                                      data-switch-value1='1||label label-success|{php echo webUrl('creditshop/goods/property',array('type'=>'istop', 'value'=>0,'id'=>$row['id']))}'
                                  {/if}>
                                  置顶</span>
                                <span class='label {if $row['isrecommand']==1}label-success{else}label-default{/if}'
                                  {ifp 'creditshop.goods.edit'}
                                      data-toggle='ajaxSwitch'
                                      data-switch-value='{$row['isrecommand']}'
                                      data-switch-value0='0||label label-default|{php echo webUrl('creditshop/goods/property',array('type'=>'isrecommand', 'value'=>1,'id'=>$row['id']))}'
                                      data-switch-value1='1||label label-success|{php echo webUrl('creditshop/goods/property',array('type'=>'isrecommand', 'value'=>0,'id'=>$row['id']))}'
                                  {/if}>
                                  推荐</span>
                                <span class='label {if $row['status']==1}label-success{else}label-default{/if}'
                                  {ifp 'creditshop.goods.edit'}
                                      data-toggle='ajaxSwitch'
                                      data-switch-value='{$row['status']}'
                                      data-switch-value0='0|暂停|label label-default|{php echo webUrl('creditshop/goods/property',array('type'=>'status', 'value'=>1,'id'=>$row['id']))}'
                                      data-switch-value1='1|启动|label label-success|{php echo webUrl('creditshop/goods/property',array('type'=>'status', 'value'=>0,'id'=>$row['id']))}'
                                  {/if}>
                                  {if $row['status']==1}启动{else}暂停{/if}</span>
                         </td>
                         <td style="text-align: center;">
                             {ifp 'creditshop.goods.view|creditshop.goods.edit'}
                                 <a class='btn btn-default btn-sm' href="{php echo webUrl('creditshop/goods/edit',array('id' => $row['id']));}" title="{ifp 'creditshop.goods.edit'}编辑{else}查看{/if}"><i class='fa fa-edit'></i></a>
                             {/if}
                             {ifp 'creditshop.goods.delete'}
                             	<a class='btn btn-default btn-sm' data-toggle='ajaxRemove' href="{php echo webUrl('creditshop/goods/delete',array('id' => $row['id']));}" data-confirm="确定要删除该商品吗？" title="删除"><i class='fa fa-remove'></i></a>
                             {/if}
                         </td>
            </tr>
           {/loop}
        </tbody>
    </table>
    {$pager}
 
</form>
{template '_footer'}
 